<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function $(id){
        return document.getElementById(id)
        }
    function login() {
        let req = new XMLHttpRequest();
        req.open('post','http://localhost:8000/user',true);
        req.setRequestHeader('content-type','application/json');
        req.onload = function (e){
            if (req.status ==200 && req.readyState==4){
                data =JSON.parse(req.responseText);
                $('result').innerHTML= data.msg;

            }

        };
        req.send(JSON.stringify({
            'name':'disen',
            'pwd': '123444'

        }))

    }

    function login(){
        let options = {
            method: 'post',
            body: JSON.stringify({
                'name':'disen',
                'pwd':'123444'}),
            headers:{
                'content-type':'application/json'
            },
            mode:'cors'
    };
        fecth('http://localhost:8000/user',options)
            .then(response=>response.json())
            .then(data=>{
                $('result').innerHTML = data.msg;})
    }
</script>

</body>
</html>